var selectShow = true;//定义下拉列表是否显示
$('.selectWrap').html($('.checkedOption').html());

/*下拉列表点击显示隐藏*/
$('.selectWrap').on('click',function(){
	if(selectShow){
		$('.optionWrap').show();
		selectShow = false;
	}else{
		$('.optionWrap').hide();
		selectShow = true;
	}
})
$('.selectMoNi img').on('click',function(){
	if(selectShow){
		$('.optionWrap').show();
		selectShow = false;
	}else{
		$('.optionWrap').hide();
		selectShow = true;
	}
})
/*下拉列表选中显示隐藏*/
$('.optionWrap').on('click','.option',function(){
	$(this).addClass('checkedOption').siblings().removeClass('checkedOption');
	$('.selectWrap').html($('.checkedOption').html());
	if(selectShow){
		console.log('show');
		$('.optionWrap').show();
		selectShow = false;
	}else{
		console.log('hide');
		$('.optionWrap').hide();
		selectShow = true;
	}
})
/*模拟单选按钮*/
$('.type b').on('click',function(){
	$(this).addClass('checkedRadio').siblings().removeClass('checkedRadio');
	$(this).parent().siblings().find('b').removeClass('checkedRadio');
})

/*提示动画*/
function tipShow(){
	$('.tip').animate({
		'opacity' : '0.8'
	},1000,function(){
		$('.tip').animate({
			'opacity' : '0'
		},2000);
	});
}
$('.submit').on('click',function(){
	var userName = $('.userInputName').val() || '';
	var userPhone = $('.userPhone').val() || '';
	console.log(userName+"========"+userPhone);
	if(Boolean(userPhone) && Boolean(userName)){
		if(Boolean($('.selectWrap').html())){
			$('#checkedRadio').val($('.selectWrap').html());
		}
		if(Boolean($('.checkedRadio').next().html())){
			$('#checkedRadio').val($('.checkedRadio').next().html());
		}
		var qq = $('.qq').val() || '';
		var type = $('#type').val() || '';
		var checkedRadio = $('.checkedRadio').next().html() || '';
		$('#textAddressValue').val($('#textAddress').val());
		var textAddressValue = $('#textAddressValue').val() || '';
		var dairuzhuleimu = $('#dairuzhuleimu').val() || '';
		$.ajax({
			type : "POST",
			url : "/eshop/pcsignupsignupaction.json",
			data:{
				"name":userName,
				'phone':userPhone,
				'qq':qq,
				'dairuzhuleimu':dairuzhuleimu,
				'type':type,
				'eshopType':checkedRadio,
				'eshopUrl':textAddressValue
				},
			dataType : "html",
			success:function(data){
				$('.submitSuccessTip').show();
				$('html').css('overflow','hidden');
				$('body').css('overflow','hidden');
			}
		})
		
	}else{
		tipShow();
	}
})
window.onscroll = function(){
	var top = document.documentElement.scrollTop || document.body.scrollTop;
	gotoTop(top);
	$('.gotoTop').on('click',function(){
		document.documentElement.scrollTop = 0;
		document.body.scrollTop = 0;
	})
}

function gotoTop(top){
	if(top > 450){
		//出现回到顶部箭头
		$('.gotoTop').show();
	}else{
		//隐藏回到顶部箭头
		$('.gotoTop').hide();
	}
}